<?php
namespace App\Service;

use App\Entity\OrderPackage;
use App\Entity\Orders;
use App\Entity\Task;
use App\Repository\ConfigRepository;
use App\Repository\ShopTagRepository;
use App\Repository\TaskVoteRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class OrderService extends ServiceEntityRepository
{

    public $shopTagRepository;
    public $configRepository;
    public $shopService;
    public $moneyService;
    public $announceService;
    public $commentService;
    public $taskVoteRepository;


    public function __construct(
        ManagerRegistry $registry
        ,AnnounceService $announceService
        ,ShopService $shopService
        ,MoneyService $moneyService
        ,ShopTagRepository $shopTagRepository
        ,ConfigRepository $configRepository
        ,CommentService $commentService
        ,TaskVoteRepository $taskVoteRepository
    )
    {
        parent::__construct($registry, Orders::class);
        $this->shopTagRepository = $shopTagRepository;
        $this->configRepository = $configRepository;
        $this->shopService = $shopService;
        $this->moneyService = $moneyService;
        $this->announceService = $announceService;
        $this->commentService = $commentService;
        $this->taskVoteRepository = $taskVoteRepository;
    }


    public function dealWithOrderPay($orderId)
    {
        $order = $this->find($orderId);
        if (!$order) {
            die();
        }
        /**@var $order \App\Entity\Orders */
        $order->setStatus(300)->setPayAt(new \DateTime());
        $this->_em->persist($order);
        $this->_em->flush();
        return true;
    }
}